<template>
  <TableView :table-attrs="{ api: getList }" :toolbar-attrs="{ buttons: ['back'] }">
    <template #columns>
      <TableColumn label="当前状态" prop="processStatusName" width="100px" />
      <TableColumn label="事项名称" clickable prop="formName" :cell-click="onRowClick" />
      <TableColumn label="办理环节" prop="name" />
      <TableColumn label="提交人" prop="startPersonName" />
      <TableColumn label="提交时间" prop="startTime" />
      <TableColumn label="总耗时" prop="totalTime" />
      <TableColumn label="所属系统" prop="appName" />
    </template>
  </TableView>
</template>

<script>
  import { getApplyedTasksPagerModel } from '@/api/admin/workitem'
  import { genPageResponse } from '@/util/response'

  export default {
    name: 'WorkDone',
    methods: {
      async getList(page) {
        const res = await getApplyedTasksPagerModel({
          entity: {},
          query: { pageNum: page.current, pageSize: page.size }
        })
        return {
          data: genPageResponse(res.data.data.rows)
        }
      },
      onRowClick(row) {
        if (!row.formUrl) {
          this.$message.warning('文档类型未配置!')
          return
        }
        this.$router.push({ path: row.formUrl.replace(':id', row.formId), query: { taskId: row.taskId } })
      }
    }
  }
</script>
